

// 128.最长连续序列
class Solution {
public:
    int longestConsecutive(vector<int>& nums) {
        // 哈希表
        unordered_set<int> s(nums.begin() , nums.end());
        int ret = 0;
        for(int x : s)
        {
            if(s.count(x - 1)) continue;

            int start = x++;
            while(s.count(x)) x++;
            ret = max(ret , x - start);
        }
        return ret;
    }
};